"""
主要测试cnode社区的话题相关的功能
主要api包括
1.   主题首页
"""
#引入第三方模块
import  requests
def test_topic_page():
    """
    测试主题首页功能
    get 请求方法
    url：http://49.233.108.117:3000/api/v1/topic
    :return:
    """
    getdata = {
        "page": 1,
        "tab": "ask",
        "limit": 100,
        "mdrender": "true"
    }

    # 1.发送get请求
    url = "http://49.233.108.117:3000/api/v1/topics"
    res = requests.get(url)
    #2.查看状态码
    print('状态码：',res.status_code)  #内置的查看状态码命令  status_code
    #3.查看json结果
    print(res.json())

    jsondata = res.json()
    data = jsondata['data']
    print(len(data))

    for d in data:
        print(d['tab'])
        if d['tab'] !='ask':
            print("数据验证失败")
test_topic_page()


# def test_create_topic():
#     """
#     创建主题
#     :return:
#     """
#     create_url = "http://49.233.108.117:3000/api/v1/topics"
#     post_data = {"accesstoken":"8aac85ba-e4b2-4093-ac23-b4154fcca626",
#                  "title":"helloword",
#                  "tab":"ask",
#                  "content":"haha"}
#     res = requests.post(url=create_url,data=post_data)
#     print(res.status_code)   #查看状态码
#     print(res.json())  #查看json
# test_create_topic()  #调用这个函数结果
#
#
# def test_topic_detail():
#     """
#     主题详情
#     :return:
#     """
#
#
# def test_topic_update():
#     """
#     编辑主题
#     :return:
#     """
# def test_topic_collect():
#     """
#     收藏主题
#
#     :return:
#     """
# def test_topic_collect_de_collect():
#     """
#     取消主题
#
#     :return:
#     """
# def test_topic_collect_loginname():
#     """
#     用户所收藏的主题
#
#     :return:
#     """
# def test_topic_id_replies():
#     """
#     新建评论
#
#     :return:
#     """
# def test_reply_id_ups():
#     """
#     为评论点赞
#
#     :return:
#     """
# def test_user_loginname():
#     """
#     用户详情
#
#     :return:
#     """
# def test_accesstoken():
#     """
#     验证accessToken的正确性
#
#     :return:
#     """
# def test_message_count():
#     """
#     获取未读消息数
#
#     :return:
#     """
# def test_messages():
#     """
#     获取未读和已读消息数
#
#     :return:
#     """
# def test_message_mar_all():
#     """
#     标记全部已读
#
#     :return:
#     """
# def test_message_mark_one_msg_id():
#     """
#     标记单个消息为已读
#
#     :return:
#     """